package com.sunxueqi.project.system.service.impl;

import java.sql.Timestamp;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sunxueqi.common.constant.StatusConstants;
import com.sunxueqi.common.utils.KeyGenerate;
import com.sunxueqi.common.utils.SecurityUtils;
import com.sunxueqi.project.system.dao.DictInfoMapper;
import com.sunxueqi.project.system.service.IDictInfoService;
import com.sunxueqi.project.system.vo.DictInfo;

@Service
public class DictInfoServiceImpl implements IDictInfoService{

	@Autowired
	private DictInfoMapper dictInfoMapper;
	
	@Override
	public List<DictInfo> selectDictInfoByType(String dictType) {
		return dictInfoMapper.selectDictInfoByType(dictType);
	}

	@Override
	public int add(DictInfo dictInfo) {
		dictInfo.setId(KeyGenerate.getKeyId());
		dictInfo.setDeleteStatus(StatusConstants.NORMAL);
		dictInfo.setCreateBy(SecurityUtils.getLoginUserId());
		dictInfo.setCreateTime(new Timestamp(System.currentTimeMillis()));
		return dictInfoMapper.insert(dictInfo);
	}

	@Override
	public List<DictInfo> selectDictInfoList(DictInfo dictInfo) {
		return dictInfoMapper.selectList(dictInfo);
	}

	@Override
	public int changeStatus(DictInfo dictInfo) {
		return dictInfoMapper.updateByPrimaryKey(dictInfo);
	}

}
